package edu.ahut.corejava2;

/**
 * 1. 构造方法的重载和委托
 * 2. 私有字段的读写器 getter setter
 * 3. 字符串化方法 toString
 */
public class Point {

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }

    public Point(int x, int y) {
        this.x = x;
        this.y = y;

    }

    public Point(int x) {
        this(x, 0);
    }

    public Point() {
        this(0);
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    private int x;
    private int y;

    void f() {
        this.x++;
    }

    public static void main(String[] args) {
        Point p = new Point();
        p.setX(p.getX() + 1);
        System.out.println(p.toString());//(x,y)
    }
}
